package booyah.validation;

import booyah.application.User;

import org.springframework.util.StringUtils;
import org.springframework.validation.Errors;


public class UserValidator {

    public static void validate(User user, Errors errors) {
        if (!StringUtils.hasLength(user.getFirstName())) {
            errors.rejectValue("firstName", "required", "required");
        }
        if (!StringUtils.hasLength(user.getLastName())) {
            errors.rejectValue("lastName", "required", "required");
        }
        if (!StringUtils.hasLength(user.getEmail())) {
            errors.rejectValue("email", "required", "required");
        }
        if (!StringUtils.hasLength(user.getPassword())) {
            errors.rejectValue("password", "required", "required");
        }

    }

}
